package day13;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;
public class D13_3 {
    public static void main(String[] args) {
        UserSysytem userSysytem=new  UserSysytem();
        userSysytem.register();
        userSysytem.login();
    }
}
class user{
    private String username;
    private String password;
    public user(String username,String password){
        this.password=password;
        this.username=username;
    }

    public String getPassword() {
        return password;
    }

    public String getUsername() {
        return username;
    }
}
class UserSysytem{
    private List<user>users=new ArrayList<>();
    Scanner scanner=new Scanner(System.in);
    public void register(){
        System.out.println("请输入用户名：");
        String username=scanner.nextLine();
        System.out.println("请输入密码：");
        String password=scanner.nextLine();
        users.add(new user(username,password));
        System.out.println("注册成功！");
    }
    public void login() {
        System.out.println("请输入用户名：");
        String username = scanner.nextLine();
        System.out.println("请输入密码：");
        String password = scanner.nextLine();
        for (user user:users){
            if (user.getUsername().equals(username)&&user.getPassword().equals(password)){
                System.out.println("登陆成功！");
                return;
            }
        }
        System.out.println("登陆失败！");
    }
}

